<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

	<h:panelGrid width="80%" columns="2"
		columnClasses="introCol1,introCol2">
		<h:outputText value="#{messages['txt.land_use']}" />
		<h:panelGroup>
			<h:panelGroup rendered="#{not readonly}">
				<h:panelGroup id="grpLandUse">
					<h:inputText readonly="true" style="width:60%"
						value="#{operationPermitHelper.selectedLandUseName}" />
					<h:inputHidden id="txtLandUse" label="#{messages['txt.land_use']}"
						value="#{operationPermitHelper.selectedLandUseName}" required="true" />
				</h:panelGroup>
				<a4j:commandLink ajaxSingle="true"
					oncomplete="#{rich:component('selectLandUsePanel')}.show()">
					<f:setPropertyActionListener
						target="#{selectLandUseHelper.returnValueField}"
						value="operationPermitHelper.permit.landUse" />
					<f:setPropertyActionListener
						target="#{selectLandUseHelper.reRenderComponents}"
						value="grpLandUse" />
					<h:outputText value="#{messages['intro.search']}" />
				</a4j:commandLink>
				<br />
				<rich:message style="color:Red;" for="txtLandUse" />
			</h:panelGroup>
			<h:panelGroup rendered="#{readonly}">
				<h:inputText readonly="true" style="width:60%"
					value="#{operationPermitHelper.selectedLandUseName}" />
			</h:panelGroup>
		</h:panelGroup>

		<h:outputText value="Otros usos" />
		<h:panelGroup id="otherLandUsesGrp">
			<h:panelGroup rendered="#{not readonly}">
				<a4j:commandLink ajaxSingle="true"
					oncomplete="#{rich:component('selectLandUsePanel')}.show()">
					<f:setPropertyActionListener
						target="#{selectLandUseHelper.addingToList}" value="#{true}" />
					<f:setPropertyActionListener
						target="#{selectLandUseHelper.addToListMethod}"
						value="operationPermitHelper.addLandUse" />
					<f:setPropertyActionListener
						target="#{selectLandUseHelper.returnValueField}"
						value="operationPermitHelper.selectedLandUse" />
					<f:setPropertyActionListener
						target="#{selectLandUseHelper.reRenderComponents}"
						value="otherLandUses" />
					<h:outputText value="#{messages['intro.search']}" />
				</a4j:commandLink>
				<br />
				<br />
				<h:panelGroup id="otherLandUses">
					<h:panelGroup
						rendered="#{not empty operationPermitHelper.permit.otherLandUses}">
						<rich:dataGrid var="landUse"
							value="#{operationPermitHelper.permit.otherLandUses}"
							columns="2">
							<table style="width: 200px">
								<tr>
									<td style="width: 70%"><h:outputText
											value="#{selectLandUseHelper.landUseName(landUse)}" /></td>
									<td><a4j:commandLink ajaxSingle="true" value="Eliminar"
											action="#{operationPermitHelper.deleteLandUse(landUse)}"
											reRender="otherLandUses">
										</a4j:commandLink></td>
								</tr>
							</table>
						</rich:dataGrid>
					</h:panelGroup>
					<h:panelGroup
						rendered="#{empty operationPermitHelper.permit.otherLandUses}">
						#{messages['txt.land_uses_select']}
					</h:panelGroup>
				</h:panelGroup>
			</h:panelGroup>
			<h:panelGroup rendered="#{readonly}">
				<h:panelGroup
					rendered="#{not empty operationPermitHelper.permit.otherLandUses}">
					<rich:dataGrid var="landUse"
						value="#{operationPermitHelper.permit.otherLandUses}"
						columns="2">
						<table style="width: 200px">
							<tr>
								<td style="width: 70%"><h:outputText
										value="#{selectLandUseHelper.landUseName(landUse)}" /></td>
								<td><a4j:commandLink ajaxSingle="true" value="Eliminar"
										action="#{operationPermitHelper.deleteLandUse(landUse)}"
										reRender="otherLandUses">
									</a4j:commandLink></td>
							</tr>
						</table>
					</rich:dataGrid>
				</h:panelGroup>
				<h:panelGroup
					rendered="#{empty operationPermitHelper.permit.otherLandUses}">
					#{messages['txt.land_uses_select']}
				</h:panelGroup>
			</h:panelGroup>
		</h:panelGroup>
	</h:panelGrid>

</ui:composition>
